/*
 * COPYRIGHT. HSBC HOLDINGS PLC 2009. ALL RIGHTS RESERVED.
 * 
 * This software is only to be used for the purpose for which it has been
 * provided. No part of it is to be reproduced, disassembled, transmitted,
 * stored in a retrieval system nor translated in any human or computer
 * language in any way or for any other purposes whatsoever without the prior
 * written consent of HSBC Holdings plc.
 */
package net.jonbuck.tassoo.eventmanager.events;

import org.apache.commons.lang.builder.ToStringBuilder;


/**
 * <p>
 * <b> Represents an Error Event within the Contact Bar. </b>
 * </p>
 * 
 * @see com.hsbc.group.contactbar.listener.ErrorEventListener
 * @since 1.0.0
 */
public class ErrorEvent implements TassooEvent {

	/** The simple class name used for logging purposes. */
//	private static final String CLASS_NAME = ErrorEvent.class.getSimpleName();

	/**
	 * The error code.
	 */
	private String code;

	/**
	 * The error description.
	 */
	private String description;

	/**
	 * Creates a new ErrorEvent object using the code and description that is
	 * passed in.
	 * 
	 * @param codeValue
	 *            the error code.
	 * @param descriptionValue
	 *            the error description.
	 */
	public ErrorEvent(final String codeValue, final String descriptionValue) {
		super();
		this.code = codeValue;
		this.description = descriptionValue;
	}

	/**
	 * Dispatch the ErrorEvent to the listener being passed in.
	 * 
	 * @param listener
	 *            an Object implementing the ErrorEventListener interface.
	 * @since 1.0.0
	 */
	public final void dispatchEvent(final Object listener) {
//		final String methodName = "dispatchEvent"; //$NON-NLS-1$
//		final String loggerName = MessageFormat.format(LoggingConstants.LOGGER_NAME, new Object[] { ErrorEvent.CLASS_NAME,
//				methodName });
//		final Logger debugLogger = LoggingPlugin.getLogManager().getLogger(
//				MessageFormat.format(LoggingConstants.DEBUG_LOGGER, new Object[] { loggerName }));
//		final Logger errorLogger = LoggingPlugin.getLogManager().getLogger(
//				MessageFormat.format(LoggingConstants.ERROR_LOGGER, new Object[] { loggerName }));
//
//		if (listener instanceof ErrorEventListener) {
//			debugLogger.trace(NLS.bind(DebugMessages.dispatchEvent, listener.getClass().getSimpleName()));
//			final ErrorEventListener eventListener = (ErrorEventListener) listener;
//			eventListener.processErrorEvent(this.code, this.description);
//		} else {
//			final String errorMessage = NLS.bind(ErrorMessages.unsupportedListenerException,
//					ErrorEventListener.class.getSimpleName(), ErrorEvent.CLASS_NAME);
//			errorLogger.error(errorMessage);
//			throw new UnsupportedListenerException(ErrorCodes.UNSUPPORTED_LISTENER_EXCEPTION, errorMessage);
//		}
	}

	/**
	 * @return the code
	 */
	public final String getCode() {
		return this.code;
	}

	/**
	 * @return the description
	 */
	public final String getDescription() {
		return this.description;
	}

	/**
	 * @param codeValue
	 *            the code to set
	 */
	public final void setCode(final String codeValue) {
		this.code = codeValue;
	}

	/**
	 * @param descriptionValue
	 *            the description to set
	 */
	public final void setDescription(final String descriptionValue) {
		this.description = descriptionValue;
	}

	/**
	 * Returns a string representation of the object. In general, the
	 * <code>toString</code> method returns a string that "textually represents"
	 * this object. The result should be a concise but informative
	 * representation that is easy for a person to read.
	 * 
	 * @return a string representation of the object.
	 */
	public String toString() {
		return new ToStringBuilder(this).append("Code", this.code).append("Description", this.description).toString();
	}

}
